var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
    })(e, t);
}, function(e, t) {
    function n() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
    new n());
}), a = this && this.__decorate || function(e, t, n, o) {
    var a, i = arguments.length, s = i < 3 ? t : null === o ? o = Object.getOwnPropertyDescriptor(t, n) : o;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, n, o); else for (var c = e.length - 1; 0 <= c; c--) (a = e[c]) && (s = (i < 3 ? a(s) : 3 < i ? a(t, n, s) : a(t, n)) || s);
    return 3 < i && s && Object.defineProperty(t, n, s), s;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("Global"), s = e("PersonView"), c = e("AudioManager"), l = e("PetManager"), d = e("GameData"), u = e("EggsManager"), p = e("DataManager"), h = e("LoadManager"), f = cc._decorator, g = f.ccclass, m = f.property, y = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.personView = null, e.bone = null, e.rope = null, e.ele = null, e.sketeon = null, 
        e.statusMap = new Map(), e.fillRange = 0, e.isHide = !1, e;
    }
    return i(e, t), e.prototype.onLoad = function() {
        var t = this;
        -1 != u.default.getInstance().checkEggPet(0) || l.default.getInstance().getConfig(0).form < 2 ? this.node.destroy() : (this.statusMap.set("pet", !1), 
        this.statusMap.set("bone", !1), this.hideAnimation(), cc.systemEvent.on("eggs_bone", function(e) {
            cc.log(e), e ? (t.node.active = !0, t.showAmimation(), h.default.getInstance().loadRes({
                url: "skeleton/bone" + l.default.getInstance().getPetIdx() + "/dog",
                type: sp.SkeletonData
            }).then(function(e) {
                t.sketeon.skeletonData = e;
            })) : t.node.active = !1;
        }, this));
    }, e.prototype.onDestroy = function() {
        cc.systemEvent.off("eggs_bone");
    }, e.prototype.onClick = function() {
        var e = this;
        -1 == u.default.getInstance().checkEggPet(0) && (c.default.getInstance().playAudio("按钮2"), 
        this.playAnimation({
            animation: this.rope,
            name: "rope",
            flag: !1
        }), this.playAnimation({
            animation: this.bone,
            name: "bone",
            flag: !1
        }), this.fillRange < .3 ? this.fillRange += .06 * Math.random() + .08 : this.fillRange < .8 ? this.fillRange += .04 * Math.random() + .06 : this.fillRange < 1 ? this.fillRange += .02 * Math.random() + .06 : (u.default.getInstance().updateEggPet(0), 
        r.G.tryPetIdx = 2, d.GD.lastPetDataIdx = d.GD.petDataIdx, d.GD.petDataIdx = 0, p.default.getInstance().save(), 
        this.playAnimation({
            animation: this.rope,
            name: "rope2",
            flag: !0
        }), this.playAnimation({
            animation: this.bone,
            name: "bone2",
            flag: !0,
            success: function() {
                e.rope.node.active = !1, e.bone.node.active = !1, e.sketeon ? (e.personView.node.active = !1, 
                e.sketeon.node.active = !0, e.sketeon.setAnimation(0, "chigutou", !1), e.sketeon.setCompleteListener(function() {
                    e.sketeon.setCompleteListener(null), e.sketeon.node.active = !1, e.personView.node.active = !0, 
                    e.doEffect();
                })) : e.doEffect();
            }
        })));
    }, e.prototype.start = function() {}, e.prototype.showAmimation = function() {
        this.isHide = !1, this.bone.node.active = !0, this.rope.node.active = !0, this.ele.node.active = !0;
    }, e.prototype.hideAnimation = function() {
        this.isHide = !0, this.bone.node.active = !1, this.rope.node.active = !1, this.ele.node.active = !1;
    }, e.prototype.playAnimation = function(e) {
        var t = this;
        !e.flag && this.statusMap.has(e.name) || this.statusMap.set(e.name, !1), this.statusMap.get(e.name) || (this.statusMap.set(e.name, !0), 
        e.animation.play(e.name), e.animation.on("finished", function() {
            t.statusMap.set(e.name, !1), e.success && e.success();
        }));
    }, e.prototype.doEffect = function() {
        var e = this;
        this.playAnimation({
            animation: this.ele,
            name: "ele",
            flag: !1,
            success: function() {
                e.personView.initPet(r.G.tryPetIdx, function() {
                    e.personView.skeleton.setAnimation(0, "move3", !1), e.personView.skeleton.setEventListener(function(e, t) {
                        "heti" == t.data.name ? c.default.getInstance().playAudio("狗组合部件音效") : "guangquan" == t.data.name && (c.default.getInstance().playAudio("狗组合部件音效"), 
                        c.default.getInstance().playAudio("光圈出现音效"));
                    }), e.personView.skeleton.setCompleteListener(function() {
                        e.personView.skeleton.setCompleteListener(null), e.personView.skeleton.setAnimation(0, "move2", !0), 
                        e.node.destroy();
                    });
                });
            }
        });
    }, e.prototype.update = function() {
        this.fillRange < 1 && 0 < this.fillRange && (this.fillRange -= .005);
    }, a([ m(s.default) ], e.prototype, "personView", void 0), a([ m(cc.Animation) ], e.prototype, "bone", void 0), 
    a([ m(cc.Animation) ], e.prototype, "rope", void 0), a([ m(cc.Animation) ], e.prototype, "ele", void 0), 
    a([ m(sp.Skeleton) ], e.prototype, "sketeon", void 0), a([ g ], e);
}(cc.Component);

n.default = y;